<template>
  <div id="barcode1">
    <div class="barcode">
      <div class="header">
        <div class="pic">
          <img :src="headimgurl">
        </div>
        <div class="msg">
          <p>{{nickname}}</p>
          <p>{{tel}}</p>
        </div>
      </div>
      <div class="txm">
        <barcode v-if="tel !== ''" class="txm1" :value = 'tel' :options="{ displayValue: true }"></barcode>
      </div>
    </div>
  </div>
</template>
<script>
  import Vue from 'vue'
  import VueBarcode from 'vue-barcode'
  Vue.component('barcode', VueBarcode)
  export default {
    name: 'barcode1',
    data () {
      return {
        tel: '',
        headimgurl: '',
        nickname: ''
      }
    },
    created () {
      this.getInfo()
    },
    methods: {
      // 获取用户信息
      getInfo () {
        this.$axios.post(this.apidomain + '/api/cust/getFansInfoByOpenId/' + this.getCookie('appid'), {
          openId: this.getCookie('openid')
        })
        .then((response) => {
          this.tel = response.data.data.mobile
          this.nickname = response.data.data.nick_name
          this.headimgurl = response.data.data.head_img_url
        })
        .catch((error) => {
          console.log(error)
        })
      }
    }
  }
</script>
<style lang="less">
  @import "../../assets/less/barcode/barcode.less";
</style>
